{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5.0"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def duration(per_chg_price, chg_yld):\n",
    "    '''\n",
    "    Summary: Calculate the duration of a bond.\n",
    "    \n",
    "    PARA per_chg_price: The percentage change in bond price.\n",
    "    PARA type: float\n",
    "    \n",
    "    PARA chg_yld: The yield change in percent.\n",
    "    PARA type: float\n",
    "   \n",
    "    '''\n",
    "    \n",
    "    return -(per_chg_price / chg_yld)\n",
    "\n",
    "#EXAMPLE\n",
    "price_change = -.05\n",
    "yield_change = .01\n",
    "duration(price_change, yield_change)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.0025000000000000022"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def absolute_yield_spread(yield_higher, yield_lower):\n",
    "    '''\n",
    "    Summary: Calculate the absolute yield spread given two bonds.\n",
    "    \n",
    "    PARA yield_higher: The yield on the higher-yield bond.\n",
    "    PARA type: float\n",
    "    \n",
    "    PARA yield_lower: The yield on the lower-yield bond.\n",
    "    PARA type: float\n",
    "   \n",
    "    '''\n",
    "    \n",
    "    return (yield_higher - yield_lower)\n",
    "\n",
    "#EXAMPLE\n",
    "y_h = .0675\n",
    "y_l = .0650\n",
    "absolute_yield_spread(y_h, y_l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.03846153846153849"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def relative_yield_spread(absolute_yield, yield_benchmark):\n",
    "    '''\n",
    "    Summary: Calculate the relative yield spread of a given bond.\n",
    "    \n",
    "    PARA absolute_yield: The the absolute yield spread for two given bonds.\n",
    "    PARA type: float\n",
    "    \n",
    "    PARA yield_benchmark: The yield of the bond that we are defining as the benchmark, the one we want to compare.\n",
    "    PARA type: float\n",
    "   \n",
    "    '''\n",
    "    \n",
    "    return absolute_yield / yield_benchmark\n",
    "\n",
    "#EXAMPLE\n",
    "y_h = .0675\n",
    "y_l = .0650\n",
    "y_a = absolute_yield_spread(y_h, y_l)\n",
    "relative_yield_spread(y_a, y_l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.0384615384615385"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def yield_ratio(subject_yield, benchmark_yield):\n",
    "    '''\n",
    "    Summary: Calculate the yield ratio, given two bonds.\n",
    "    \n",
    "    PARA subject_yield: The yield of the subject bond.\n",
    "    PARA type: float\n",
    "    \n",
    "    PARA benchmark_yield: The yield of the bond that we are defining as the benchmark, the one we want to compare.\n",
    "    PARA type: float\n",
    "   \n",
    "    '''\n",
    "    \n",
    "    return subject_yield / benchmark_yield\n",
    "\n",
    "#EXAMPLE\n",
    "y_h = .0675\n",
    "y_l = .0650\n",
    "yield_ratio(y_h, y_l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.06"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def after_tax_yield(taxable_yield, marginal_tax_rate):\n",
    "    '''\n",
    "    Summary: Calculate the after-tax yield on a taxable security.\n",
    "    \n",
    "    PARA taxable_yield: The taxable yield of a bond.\n",
    "    PARA type: float\n",
    "    \n",
    "    PARA marginal_tax_rate: The investor's marginal tax rate.\n",
    "    PARA type: float\n",
    "   \n",
    "    '''\n",
    "    \n",
    "    return taxable_yield * (1 - marginal_tax_rate)\n",
    "\n",
    "#EXAMPLE\n",
    "yld_tax = .10\n",
    "mrg_tax = .40\n",
    "after_tax_yield(yld_tax, mrg_tax)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.06923076923076922"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def taxable_equivalent_yield(tax_free_yield, marginal_tax_rate):\n",
    "    '''\n",
    "    Summary: Calculate the taxable-equivalent yield for a given bond.\n",
    "    \n",
    "    PARA tax_free_yield: The tax-free yield of a bond.\n",
    "    PARA type: float\n",
    "    \n",
    "    PARA marginal_tax_rate: The investor's marginal tax rate.\n",
    "    PARA type: float\n",
    "   \n",
    "    '''\n",
    "    \n",
    "    return tax_free_yield / (1 - marginal_tax_rate)\n",
    "\n",
    "#EXAMPLE\n",
    "yld_tax = .045\n",
    "mrg_tax = .350\n",
    "taxable_equivalent_yield(yld_tax, mrg_tax)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "9.416299559471366"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def effective_duration(bond_dec, bond_inc, bond_int, yld_delta):\n",
    "    '''\n",
    "    Summary: Calculate the effective duration of a bond, given a change in yield.\n",
    "    \n",
    "    PARA bond_dec: The value of a bond is the yield decreases by the yield_delta.\n",
    "    PARA type: float\n",
    "    \n",
    "    PARA bond_inc: The value of a bond is the yield increases by the yield_delta.\n",
    "    PARA type: float\n",
    "    \n",
    "    PARA bond_int: The inital bond price.\n",
    "    PARA type: float\n",
    "    \n",
    "    PARA yld_delta: The change in yield to get bond_dec & bond_inc\n",
    "    PARA type: float\n",
    "   \n",
    "    '''  \n",
    "    \n",
    "    return (bond_inc - bond_dec) / (2 * bond_int * yld_delta)\n",
    "    \n",
    "#EXAMPLE\n",
    "bond_inc = 952.30\n",
    "bond_dec = 866.80\n",
    "bond_int = 908.00\n",
    "delt_yld = .005\n",
    "effective_duration(bond_dec, bond_inc, bond_int, delt_yld)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-0.028248898678414097"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def pct_change_bond(effective_duration, yld_chg):\n",
    "    '''\n",
    "    Summary: Calculate the percentage change in bond price.\n",
    "    \n",
    "    PARA effective_duration: The effective duration of the bond.\n",
    "    PARA type: float\n",
    "    \n",
    "    PARA yld_chg: The percentage change in yield.\n",
    "    PARA type: float\n",
    "   \n",
    "    '''     \n",
    "    \n",
    "    return -effective_duration * yld_chg\n",
    "\n",
    "#EXAMPLE\n",
    "bond_inc = 952.30\n",
    "bond_dec = 866.80\n",
    "bond_int = 908.00\n",
    "delt_yld = .005\n",
    "ed = effective_duration(bond_dec, bond_inc, bond_int, delt_yld)\n",
    "\n",
    "pct_yld = .003\n",
    "pct_change_bond(ed, pct_yld)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "6.699999999999999"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "def portfolio_duration(bonds, durations):\n",
    "    '''\n",
    "    Summary: Calculate the duration of a portfolio given a list of bond prices, and a list of durations for each bonds.\n",
    "    \n",
    "    PARA bonds: A list of bonds at their market value prices\n",
    "    PARA type: float\n",
    "    \n",
    "    PARA durations: A list of durations for each bond in the bonds list\n",
    "    PARA type: float\n",
    "   \n",
    "    '''         \n",
    "    \n",
    "    # calculate the weights\n",
    "    np_bonds = np.array(bonds)\n",
    "    np_weights = np_bonds / np_bonds.sum()\n",
    "    \n",
    "    np_durations = np.array(durations)\n",
    "    \n",
    "    return np.dot(np_weights, np_durations)\n",
    "\n",
    "#EXAMPLE\n",
    "bond = [6000, 4000]\n",
    "dura = [8.5, 4.0]\n",
    "portfolio_duration(bond, dura)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.048"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "0.04940625"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "def return_impact(mod_duration, spread, spread_type, convexity):\n",
    "    '''\n",
    "    Summary: Calculate the return impact for a bond, using either a large or small spread.\n",
    "    \n",
    "    PARA mod_duration: The modified duration of the bond.\n",
    "    PARA type: float\n",
    "    \n",
    "    PARA spread: The change in spread\n",
    "    PARA type: float\n",
    "    \n",
    "    PARA spread_type: Defines the spread as either a small spread change or large spread change. Options are 'large' or 'small'\n",
    "    PARA type: string\n",
    "    \n",
    "    PARA convexity: The spread convexity\n",
    "    PARA type: float    \n",
    "   \n",
    "    '''             \n",
    "    \n",
    "    if spread_type == 'small':\n",
    "        \n",
    "        return -mod_duration * spread\n",
    "        \n",
    "    else:\n",
    "        \n",
    "        return (-mod_duration * spread) + (.5 * convexity * (spread ** 2))\n",
    "    \n",
    "\n",
    "#EXAMPLE\n",
    "duration = 6.4\n",
    "convexity = 50\n",
    "spread = -.0075\n",
    "\n",
    "# small example\n",
    "spread_type = 'small'\n",
    "display(return_impact(duration, spread, spread_type, convexity))\n",
    "\n",
    "# large example\n",
    "spread_type = 'large'\n",
    "display(return_impact(duration, spread, spread_type, convexity))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('out-of-the-money', -3.0)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "('in-the-money', 3.0)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "def option_moneyness(option_type, strike_price, selling_price):\n",
    "    '''\n",
    "    Summary: Returns whether a put option or call option is in the money, at the money, or out the money.\n",
    "    \n",
    "    PARA option_type: Defines whether the option is a 'call' or 'put' option.\n",
    "    PARA type: string\n",
    "    \n",
    "    PARA strike_price: The strike price of the option.\n",
    "    PARA type: float\n",
    "    \n",
    "    PARA selling_price: The current selling price of the option\n",
    "    PARA type: float \n",
    "   \n",
    "    '''     \n",
    "    \n",
    "    # describe the conditions for a call option\n",
    "    if option_type == 'call':\n",
    "        \n",
    "        if (selling_price - strike_price) > 0:            \n",
    "            return ('in-the-money', selling_price - strike_price)\n",
    "        \n",
    "        elif (selling_price - strike_price) < 0:            \n",
    "            return ('out-of-the-money', selling_price - strike_price)\n",
    "        \n",
    "        elif(selling_price == strike_price):            \n",
    "            return ('at-the-money', 0)\n",
    "        \n",
    "    # describe the condtions for a put option\n",
    "    else:\n",
    "    \n",
    "        if (strike_price - selling_price) > 0:            \n",
    "            return ('in-the-money', strike_price - selling_price)\n",
    "        \n",
    "        elif (strike_price - selling_price) < 0:            \n",
    "            return ('out-of-the-money', strike_price - selling_price)\n",
    "        \n",
    "        elif(selling_price == strike_price):            \n",
    "            return ('at-the-money', 0)\n",
    "        \n",
    "# EXAMPLE\n",
    "selling_price = 37.00\n",
    "strike_price = 40.00\n",
    "\n",
    "# call example\n",
    "opt_type = 'call'\n",
    "display(option_moneyness(opt_type, strike_price, selling_price))\n",
    "\n",
    "# put example\n",
    "opt_type = 'put'\n",
    "display(option_moneyness(opt_type, strike_price, selling_price))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3000.0"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def exp_date_payoff(exercise_price, index_price, contracts):\n",
    "    '''\n",
    "    Summary: Returns the expiration date payoff for a option.\n",
    "    \n",
    "    PARA exercise_price: The exercise price of the option.\n",
    "    PARA type: float\n",
    "    \n",
    "    PARA index_price: The index price at expiration.\n",
    "    PARA type: float\n",
    "    \n",
    "    PARA contracts: The contract multiplier\n",
    "    PARA type: int\n",
    "   \n",
    "    '''       \n",
    "    \n",
    "    return (index_price - exercise_price) * contracts\n",
    "\n",
    "# EXAMPLE\n",
    "i_price = 962.00\n",
    "e_price = 950.00\n",
    "cont = 250\n",
    "exp_date_payoff(e_price, i_price, cont)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5.0"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "def option_intrinsic_value(option_type, strike_price, selling_price):\n",
    "    '''\n",
    "    Summary: Returns the intrinsic value of either a put or call option.\n",
    "    \n",
    "    PARA option_type: Defines whether the option is a 'call' or 'put' option.\n",
    "    PARA type: string\n",
    "    \n",
    "    PARA strike_price: The strike price of the option.\n",
    "    PARA type: float\n",
    "    \n",
    "    PARA selling_price: The current selling price of the option\n",
    "    PARA type: float \n",
    "   \n",
    "    '''  \n",
    "    \n",
    "    # calculate the intrinsic value of a call option\n",
    "    if option_type == 'call':\n",
    "        \n",
    "        return max([0, (selling_price - strike_price)])\n",
    "        \n",
    "    # calculate the intrinsic value of a put option\n",
    "    else:\n",
    "        \n",
    "        return max([0, (strike_price - selling_price)])\n",
    "    \n",
    "# EXAMPLE\n",
    "selling_price = 55.00\n",
    "strike_price = 50.00\n",
    "\n",
    "# call example\n",
    "opt_type = 'call'\n",
    "display(option_intrinsic_value(opt_type, strike_price, selling_price))\n",
    "\n",
    "# put example\n",
    "opt_type = 'put'\n",
    "display(option_intrinsic_value(opt_type, strike_price, selling_price))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(2.0, 65.0)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "(0.9514295424027992, 63.9514295424028)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "(3.788024417500182, 68.0)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "(3.788024417500182, 68.0)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "def min_max_option(option_type, option_style, risk_free_rate, strike_price, selling_price, time_frame):    \n",
    "    '''\n",
    "    Summary: Returns the maximum and minimum value for a european or american call/put.\n",
    "    \n",
    "    PARA option_type: Defines whether the option is a 'call' or 'put' option.\n",
    "    PARA type: string\n",
    "    \n",
    "    PARA option_style: Defines whether the option is an 'american' or 'european' option.\n",
    "    PARA type: string\n",
    "    \n",
    "    PARA risk_free_rate: The current risk-free rate.\n",
    "    PARA type: float\n",
    "    \n",
    "    PARA selling_price: The current selling price of the option.\n",
    "    PARA type: float \n",
    "        \n",
    "    PARA strike_price: The strike price of the option.\n",
    "    PARA type: float\n",
    "   \n",
    "    PARA time_frame: The time frame of the option, for example a 4 month option would be 4.\n",
    "    PARA type: float\n",
    "    \n",
    "    ''' \n",
    "    \n",
    "    if option_type == 'call':\n",
    "        \n",
    "        if option_style == 'american' or option_style == 'european':            \n",
    "            \n",
    "            max_opt_1 = 0\n",
    "            max_opt_2 = (selling_price - strike_price / (1 + risk_free_rate) **(time_frame / 12))\n",
    "            \n",
    "            minimum_value = max([max_opt_1, max_opt_2])\n",
    "            maximum_value = selling_price\n",
    "            \n",
    "            return (minimum_value, maximum_value)\n",
    "        \n",
    "    else:\n",
    "        \n",
    "        if option_style == 'american':    \n",
    "            max_opt_1 = 0\n",
    "            max_opt_2 = strike_price - selling_price\n",
    "            \n",
    "            minimum_value = max([max_opt_1, max_opt_2])\n",
    "            maximum_value = strike_price\n",
    "            \n",
    "            return (minimum_value, maximum_value)\n",
    "            \n",
    "        else:            \n",
    "            max_opt_1 = 0\n",
    "            max_opt_2 = (strike_price / (1 + risk_free_rate) **(time_frame / 12)) - selling_price\n",
    "            \n",
    "            minimum_value = max([max_opt_1, max_opt_2])\n",
    "            maximum_value = (strike_price / (1 + risk_free_rate) **(time_frame / 12))\n",
    "            \n",
    "            return (minimum_value, maximum_value)\n",
    "        \n",
    "    \n",
    "# EXAMPLE - PUTS\n",
    "selling_price = 63.00\n",
    "strike_price = 65.00\n",
    "time_frame = 4\n",
    "rfr = .05\n",
    "\n",
    "# put example\n",
    "opt_type = 'put'\n",
    "opt_styl = 'american'\n",
    "display(min_max_option(opt_type, opt_styl, rfr, strike_price, selling_price, time_frame))\n",
    "\n",
    "# put example\n",
    "opt_type = 'put'\n",
    "opt_styl = 'european'\n",
    "display(min_max_option(opt_type, opt_styl, rfr, strike_price, selling_price, time_frame))\n",
    "\n",
    "# EXAMPLE - CALLS\n",
    "selling_price = 68.00\n",
    "strike_price = 65.00\n",
    "time_frame = 3\n",
    "rfr = .05\n",
    "\n",
    "# call example\n",
    "opt_type = 'call'\n",
    "opt_styl = 'american'\n",
    "display(min_max_option(opt_type, opt_styl, rfr, strike_price, selling_price, time_frame))\n",
    "\n",
    "# call example\n",
    "opt_type = 'call'\n",
    "opt_styl = 'european'\n",
    "display(min_max_option(opt_type, opt_styl, rfr, strike_price, selling_price, time_frame))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4.106172628846302"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def put_call_parity(calc = 'none', put = 0, call = 0, strike_price = 0, stock_price = 0, risk_free_rate = 0, time_frame = 0):\n",
    "    '''\n",
    "    Summary: Define the put-call parity formula, which returns the price of a call given a put and vice verse.\n",
    "    \n",
    "    PARA calc: Calculate either the value of a 'call' given a put or calculate a 'put' given a call.\n",
    "    PARA type: string    \n",
    "    \n",
    "    PARA put: The price of the put.\n",
    "    PARA type: float\n",
    "    \n",
    "    PARA call: The price of the call\n",
    "    PARA type: float\n",
    "    \n",
    "    PARA exercise_price: The current selling price of the option.\n",
    "    PARA type: float \n",
    "        \n",
    "    PARA stock_price: The current price of the stock\n",
    "    PARA type: float\n",
    "   \n",
    "    PARA risk_free_rate: The current risk-free rate.\n",
    "    PARA type: float\n",
    "    \n",
    "    PARA time_frame: The time frame of the option, for example a 4 month option would be 4.\n",
    "    PARA type: int\n",
    "    '''\n",
    "    \n",
    "    if calc == 'put':\n",
    "        \n",
    "        put = call - stock_price + (strike_price / ((1 + risk_free_rate) ** (time_frame / 12)))         \n",
    "        return put\n",
    "    \n",
    "    else:\n",
    "\n",
    "        call = stock_price + put - (strike_price / ((1 + risk_free_rate) ** (time_frame / 12)))    \n",
    "        return call\n",
    "    \n",
    "#EXAMPLE\n",
    "stock = 52.00\n",
    "rfr = .05\n",
    "time = 3\n",
    "exercise = 50.00\n",
    "put = 1.50\n",
    "calc_type = 'call'\n",
    "put_call_parity(calc = calc_type, \n",
    "                put = put, \n",
    "                strike_price = exercise, \n",
    "                stock_price = stock, \n",
    "                risk_free_rate = rfr, \n",
    "                time_frame =time)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4999.999999999999"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def fixed_rate_pay(swap_fixed_rate, libor, principal, num_days):\n",
    "    '''\n",
    "    Summary: Define the put-call parity formula, which returns the price of a call given a put and vice verse.\n",
    "    \n",
    "    PARA calc: Calculate either the value of a 'call' given a put or calculate a 'put' given a call.\n",
    "    PARA type: string    \n",
    "    \n",
    "    PARA swap_fixed_rate: The swap's fixed rate.\n",
    "    PARA type: float\n",
    "    \n",
    "    PARA libor: The libor rate\n",
    "    PARA type: float\n",
    "    \n",
    "    PARA principal: The principal of the swap\n",
    "    PARA type: float\n",
    "    \n",
    "    PARA num_days: The number of days until payment\n",
    "    PARA type: int        \n",
    "    '''  \n",
    "    \n",
    "    return (swap_fixed_rate - libor) * (num_days / 360) * (principal)\n",
    "\n",
    "\n",
    "#EXAMPLE\n",
    "swap = .06\n",
    "libor = .04\n",
    "principal = 1000000\n",
    "days = 90\n",
    "fixed_rate_pay(swap, libor, principal, days)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
